package Eyjafjalla.action;

import Eyjafjalla.power.RedCloudPower;
import Eyjafjalla.power.WhiteCloudPower;
import com.megacrit.cardcrawl.actions.AbstractGameAction;
import com.megacrit.cardcrawl.actions.common.ApplyPowerAction;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.monsters.AbstractMonster;

public class GoodFriendAction extends AbstractGameAction {
    public GoodFriendAction(){
        this.amount = 1;
    }

    public GoodFriendAction(boolean onlyWhite,int amount){
        this.onlyWhite = onlyWhite;
        this.amount = amount;
    }

    boolean onlyWhite = false;

    @Override
    public void update() {
        boolean giveRed = AbstractDungeon.cardRandomRng.randomBoolean();
        if(onlyWhite){
            giveRed = false;
        }
        AbstractMonster m = AbstractDungeon.getRandomMonster();
        if(m!=null) {
            if (giveRed) {
                addToTop(new ApplyPowerAction(m,AbstractDungeon.player,new RedCloudPower(m,amount),amount));
            }
            else {
                addToTop(new ApplyPowerAction(m,AbstractDungeon.player,new WhiteCloudPower(m,amount),amount));
            }
        }
        this.isDone = true;
    }
}
